package hbot;

import java.util.ArrayList;

import org.opencv.core.Mat;
import org.opencv.core.Rect;
import org.opencv.imgproc.Imgproc;

public class RegionsReader {
	
	SVMClassificator m_Classificator;
	
	public RegionsReader(){
		m_Classificator = new SVMClassificator();
	}
	
	
	
	public ArrayList<Rect> getOddRegions(Mat image){
		ArrayList<Rect> oddRegions = new ArrayList<Rect>();
		
		for(int i=1; i<=7; i++){
			Rect sourceRect = new Rect(	Regions.playerMinion_X_odd[i],
										Regions.playerMinion_Y, 
										Regions.region_width, 
										Regions.region_heigth);
			
			Mat region_i = image.submat(sourceRect);
			
			// transform to greyscale
			Imgproc.cvtColor(region_i, region_i, Imgproc.COLOR_RGB2GRAY);
			//Imshow show_image1 = new Imshow("Region" + i + "after ColorConvert");
			//show_image1.showImage(region_i);
			
			Imgproc.threshold(region_i, region_i, 135, 255, Imgproc.THRESH_BINARY);
			//Imshow show_image = new Imshow("Region" + i + "after Thres");
			//show_image.showImage(region_i);
			
			if(m_Classificator.classifyRegion(region_i) == 1.0F){
				oddRegions.add(sourceRect);
			}
			
			
		}
		
		return oddRegions;
	}
	
	
}
